package yhp.com.zijie.dao.impl;

import yhp.com.zijie.bean.Grade;
import yhp.com.zijie.dao.GradeDao;
import yhp.com.zijie.util.DBUtils;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class GradeDaoImpl extends DBUtils implements GradeDao {


    @Override
    public List<Grade> showGrade() {

        List<Grade> gradeList = new ArrayList<>();
        try {
            String sql = "select * from grade";
            resultSet = query(sql, null);

            while (resultSet.next()){
                Grade grade = new Grade();
                grade.setGradeId(resultSet.getInt("gradeid"));
                grade.setGradeName(resultSet.getString("gradename"));
                gradeList.add(grade);
            }
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        } finally {
            closeAll();
        }

        return gradeList;
    }
}
